<template>
  <div class="form-design-bar">
    <div class="form-design-bar-left">
      <span class="left-text"></span>
    </div>
    <div class="form-design-bar-right">
      <a-space>
        <!-- <a-button type="link">
          {{ $t(`formDesign.styleSetting`) }}
        </a-button> -->
        <a-button type="primary" @click="onSave">
          {{ $t(`formDesign.save`) }}
        </a-button>
      </a-space>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue';
import { useStore } from 'vuex';
import { message } from 'ant-design-vue';
import { ResponseHandle } from '@/global/util/preUtils';

export default defineComponent({
  name: 'FormDesignBar',
  setup() {
    const store = useStore();
    const formProperty = computed(
      () => store.state.formDesign.form.formProperty,
    );
    const onSave = async () => {
      const dataTitle = formProperty.value.dataTitle.defaultValue;
      if (!dataTitle?.length) {
        return message.warning('数据标题不能为空');
      }
      const res = await store.dispatch('formDesign/saveForm');
      ResponseHandle(res, () => message.success('保存成功'));
    };

    return {
      onSave,
    };
  },
});
</script>

<style lang="less" scoped>
.form-design-bar {
  .flexRow(space-between);
  padding: 0 32px;
  height: 40px;
  line-height: 40px;
  background-color: @rb-body-background;
  color: @rb-text-color-light;
  z-index: 2;
  &-left {
    .left-text {
    }
  }
  &-right {
  }
}
</style>
